import xlrd


class RegisterData:

    # 正常注册
    def getSuccessData(self):

        wordBook = xlrd.open_workbook(filename='../TestData/test_register_data.xls')
        sheet = wordBook.sheet_by_name('Sheet1')
        arr = []
        for i in range(1, sheet.nrows):
            e = sheet.row_values(i)
            if type(e[1]) is float:
                e[1] = str(int(e[1]))

            if type(e[2]) is float:
                e[2] = str(int(e[2]))

            e[3] = e[3].split(',')
            if type(e[3][1]) is str:
                e[3][1] = int(e[3][1])
            arr.append(e)

        return arr

    # 重复用户进行注册
    def getRepeatUserErrorData(self):
        wordBook = xlrd.open_workbook(filename='../TestData/test_register_data.xls')
        sheet = wordBook.sheet_by_name('Sheet2')
        arr = []
        for i in range(1, sheet.nrows):
            e = sheet.row_values(i)
            if type(e[1]) is float:
                e[1] = str(int(e[1]))

            if type(e[2]) is float:
                e[2] = str(int(e[2]))

            if type(e[3]) is float:
                e[3] = int(e[3])
            arr.append(e)

        return arr

    # 密码和确认密码不一致
    def getRePwdErrorData(self):
        wordBook = xlrd.open_workbook(filename='../TestData/test_register_data.xls')
        sheet = wordBook.sheet_by_name('Sheet3')
        arr = []
        for i in range(1, sheet.nrows):
            e = sheet.row_values(i)
            if type(e[1]) is float:
                e[1] = str(int(e[1]))

            if type(e[2]) is float:
                e[2] = str(int(e[2]))

            arr.append(e)
        return arr

    # 缺少确认密码
    def getLackRePwdErrorData(self):
        wordBook = xlrd.open_workbook(filename='../TestData/test_register_data.xls')
        sheet = wordBook.sheet_by_name('Sheet4')
        arr = []
        for i in range(1, sheet.nrows):
            e = sheet.row_values(i)
            if type(e[1]) is float:
                e[1] = str(int(e[1]))

            arr.append(e)
        return arr

    # 密码和确认密码 都为空
    def getLackPwdErrorData(self):
        wordBook = xlrd.open_workbook(filename='../TestData/test_register_data.xls')
        sheet = wordBook.sheet_by_name('Sheet5')
        arr = []
        for i in range(1, sheet.nrows):
            e = sheet.row_values(i)
            arr.append(e)
        return arr
